package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import java.lang.reflect.Field;

public abstract class erz {
    private static boolean ˊ = false;
    private static boolean ˋ = false;
    private static Field ˏ = null;
    private static Integer ॱ = null;

    protected erz() {
    }

    public static boolean ˏ(Context context, String str) {
        return ((cdg) cdb.ॱ(cdg.class)).ॱॱ(str);
    }

    public static int ˎ(Context context, String str) {
        int i = -1;
        try {
            return context.getPackageManager().getPackageInfo(str, 0).versionCode;
        } catch (NameNotFoundException e) {
            Logger.e("BasePackageUtils", "getVersionCode_(Context context, String packageName) " + e.toString());
            return i;
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static java.lang.String ˋ(android.content.Context r5, java.lang.String r6) {
        /*
        r1 = 0;
        r0 = r5.getPackageManager();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r2 = 0;
        r0.getPackageInfo(r6, r2);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r2 = 64;
        r0 = r0.getPackageInfo(r6, r2);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r0.signatures;	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r2 = 0;
        r0 = r0[r2];	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        if (r0 == 0) goto L_0x00b3;
    L_0x0016:
        r0 = r0.toCharsString();	 Catch:{ Exception -> 0x003a, NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077 }
        r0 = o.doa.ˊ(r0);	 Catch:{ Exception -> 0x003a, NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077 }
        r0 = o.dnk.ˏ(r0);	 Catch:{ Exception -> 0x003a, NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077 }
        r0 = o.eux.ॱ(r0);	 Catch:{ Exception -> 0x003a, NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077 }
    L_0x0026:
        if (r0 == 0) goto L_0x0038;
    L_0x0028:
        r2 = r0.trim();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r2 = r2.length();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        if (r2 <= 0) goto L_0x0038;
    L_0x0032:
        r2 = java.util.Locale.US;	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r0.toUpperCase(r2);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
    L_0x0038:
        r1 = r0;
    L_0x0039:
        return r1;
    L_0x003a:
        r0 = move-exception;
        r2 = "BasePackageUtils";
        r3 = new java.lang.StringBuilder;	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r3.<init>();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r4 = "getSign, Exception: ";
        r3 = r3.append(r4);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r0.getMessage();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r3.append(r0);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r0.toString();	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        o.dna.ˏ(r2, r0);	 Catch:{ NameNotFoundException -> 0x0059, UnsupportedOperationException -> 0x0077, Exception -> 0x0095 }
        r0 = r1;
        goto L_0x0026;
    L_0x0059:
        r0 = move-exception;
        r2 = "BasePackageUtils";
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = "when check the caller sign, catch NameNotFoundException:";
        r3 = r3.append(r4);
        r0 = r0.getMessage();
        r0 = r3.append(r0);
        r0 = r0.toString();
        o.dna.ˏ(r2, r0);
        goto L_0x0039;
    L_0x0077:
        r0 = move-exception;
        r2 = "BasePackageUtils";
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = "when check the caller sign, catch UnsupportedOperationException:";
        r3 = r3.append(r4);
        r0 = r0.getMessage();
        r0 = r3.append(r0);
        r0 = r0.toString();
        o.dna.ˏ(r2, r0);
        goto L_0x0039;
    L_0x0095:
        r0 = move-exception;
        r2 = "BasePackageUtils";
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = "when check the caller sign, catch Exception:";
        r3 = r3.append(r4);
        r0 = r0.getMessage();
        r0 = r3.append(r0);
        r0 = r0.toString();
        o.dna.ˏ(r2, r0);
        goto L_0x0039;
    L_0x00b3:
        r0 = r1;
        goto L_0x0038;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.erz.ˋ(android.content.Context, java.lang.String):java.lang.String");
    }

    public static Integer ˋ() {
        if (ˋ) {
            return ॱ;
        }
        try {
            Class cls = Class.forName("android.content.pm.PackageParser");
            ॱ = Integer.valueOf(cls.getDeclaredField("PARSE_IS_REMOVABLE_PREINSTALLED_APK").getInt(cls));
        } catch (NoSuchFieldException e) {
            Logger.ˏ("BasePackageUtils", "isDelApp error NoSuchFieldException:" + e.toString());
        } catch (ClassNotFoundException e2) {
            Logger.ˏ("BasePackageUtils", "isDelApp error NoSuchFieldException:" + e2.toString());
        } catch (IllegalAccessException e3) {
            Logger.ˏ("BasePackageUtils", "isDelApp error NoSuchFieldException:" + e3.toString());
        } catch (IllegalArgumentException e4) {
            Logger.ˏ("BasePackageUtils", "isDelApp error NoSuchFieldException:" + e4.toString());
        }
        ˋ = true;
        return ॱ;
    }

    public static Field ˏ() {
        if (ˊ) {
            return ˏ;
        }
        try {
            ˏ = ApplicationInfo.class.getField("hwFlags");
        } catch (NoSuchFieldException e) {
            Logger.ˏ("BasePackageUtils", "can not find hwFlags");
        }
        ˊ = true;
        return ˏ;
    }

    public static int ˏ(PackageInfo packageInfo) {
        if (packageInfo == null || packageInfo.applicationInfo == null || packageInfo.applicationInfo.metaData == null || !packageInfo.applicationInfo.metaData.containsKey("com.huawei.maple.flag")) {
            return 0;
        }
        return 1;
    }
}
